var vo={};
$(function(){
	var openWindow=window.document;
	var searchHeight=$("#divform").height();
	$("#listSick").height($(openWindow).height()-$(openWindow).height()*0.05-searchHeight);
	$("#listSick").datagrid({
					url:'/devicesick/getDeviceSick',
					title:'设备不健康列表',
					method:'get',
					pagination:true,
					singleSelect:true,
					pageList: window.PageSize,
					loadMsg:'加载中......',
					nowrap:true,
					columns:[[
							 {field:'deviceid',title:'设备编号', align:'left',width:100,sortable:true},
					         {field:'devicename',title:'设备名称', align:'left',width:100,sortable:true},
					         {field:'shopid',title:'门店编号', align:'left',width:100,sortable:true},
					         {field:'shopname',title:'门店名称', align:'left',width:100,sortable:true},
					         {field:'dealerid',title:'经销商编号', align:'left',width:100,sortable:true},
					         {field:'dealername',title:'经销商名称', align:'left',width:100,sortable:true},
					         {field:'checkdate',title:'检查时间',align:'left',width:100,formatter:function(value,row,index){
					        	 if(value==''){
					        		 return '';
					        	 }
					        	 var datetime=Common.formatterDate(value);
					        	 return datetime;
					         }},
					         {field:'model',title:'说明',align:'left',width:200,formatter:function(value, row, index){
					        	 if(value==undefined){
						 				return '';
						 			}
						 			else if(value.length<13){
						 				return value;
						 			}else{
						 				return value.substr(0, 13) + '...';
						 			}
						      }}
					     ]]
				});
	var data=[{'id':'1','text':'超额'},{'id':'2','text':'未上传'}]
	$("#category").combobox({
		 data:data,
		 valueField:'id',
		 textField:'text',
	});
	$("#serbutton").click(function(){
		vo.devicename=$("#devicename").val();
		vo.deviceid=$("#deviceid").val();
		vo.shopid=$("#shopid").val();
		vo.shopname=$("#shopname").val();
		vo.dealerid=$("#dealerid").val();
		vo.dealername=$("#dealername").val();
		vo.category=$('#category').combobox('getValue');
		vo.beginTime=$('#beginTime').datebox('getValue');
		vo.endTime=$('#endTime').datebox('getValue');
		$("#listSick").datagrid('load',vo);
	});
	$("#listSick").datagrid({
		toolbar: '#tb'
	});
	$('#beginTime').datebox({});  
	$('#endTime').datebox({}); 
});
/**
 * 导出为excel
 */
function exportXls(){
	vo.shopid=getVal(vo.shopid);
	vo.shopname=getVal(vo.shopname);
	vo.dealerid=getVal(vo.dealerid);
	vo.dealername=getVal(vo.dealername);
	vo.deviceid=getVal(vo.deviceid);
	vo.devicename=getVal(vo.devicename);
	vo.category=getVal(vo.category);
	vo.beginTime=getVal(vo.begintime);
	vo.endTime=getVal(vo.endtime);
	var url='/devicesick/exportXls?shopid='+vo.shopid+'&shopname='+vo.shopname+'&dealerid='+
	vo.dealerid+'&dealername='+vo.dealername+'&deviceid='+vo.deviceid+
	'&devicename='+vo.devicename+'&category='+vo.category+'&beginTime='+vo.beginTime+'&endTime='+vo.endTime;
	window.open(url,'','',false);
}